﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ruanmou.Framework.AdoHelper
{
    public  class DelegateExtend
    {


        //Ado封装
        public static T Excute<T>(string sql, Func<SqlCommand, T> func)
        {
            using (SqlConnection conn = new SqlConnection(""))
            {
                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    SqlCommand command = new SqlCommand(sql, conn);
                    T t = func(command);
                    trans.Commit();
                    return t;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    trans.Rollback();
                    throw ex;
                }
            }

        }


    }
}
